cmake_minimum_required(VERSION 3.10)

# 收集源文件
set(MONITORING_SOURCES
    metrics.cpp
    alerting.cpp
)

# 创建监控库
add_library(common_monitoring_lib ${MONITORING_SOURCES})

# 设置包含目录
target_include_directories(common_monitoring_lib PUBLIC
    ${CMAKE_SOURCE_DIR}
)

# 添加依赖库 - 使CURL成为可选依赖
option(USE_CURL "Use libcurl for webhook notifications" OFF)
if(USE_CURL)
    find_package(CURL)
    if(CURL_FOUND)
        target_compile_definitions(common_monitoring_lib PUBLIC -DHAS_CURL)
        target_include_directories(common_monitoring_lib PUBLIC ${CURL_INCLUDE_DIRS})
        target_link_libraries(common_monitoring_lib PUBLIC ${CURL_LIBRARIES})
    else()
        message(STATUS "CURL not found, webhook functionality will be limited")
    endif()
else()
    message(STATUS "CURL support disabled")
endif()

# 安装
install(TARGETS common_monitoring_lib
    ARCHIVE DESTINATION lib
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
) 